package com.summer;

import org.elasticsearch.client.IndicesClient;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.IOException;

@SpringBootTest
public class test02 {


    @Autowired
    @Qualifier("restHighLevelClient")
    private RestHighLevelClient client;


    /*
    *   PUT /indices/types/document_ID{}
    *   测试索引的创建 indices
    */
    @Test
    private void test01() throws IOException {
        //创建一个索引的请求
        CreateIndexRequest request = new CreateIndexRequest("summer");
        //客户端执行请求，并接受返回值
        CreateIndexResponse indices = client.indices().create(request, RequestOptions.DEFAULT);
        //输出结果
        System.out.println(indices);
    }



}
